<template>
  <div class="app-container book-content">

  </div>
</template>

<script>
export default {
  data() {
    return {
      book: "",
      isMenu: false,
      active: -1,
      familyList: [
        {
          name: "雅黑"
        },
        {
          name: "宋体"
        },
        {
          name: "楷体"
        }
      ],
      sizeList: [
        {
          name: "小"
        },
        {
          name: "中"
        },
        {
          name: "大"
        },
        {
          name: "特大"
        }
      ]
    };
  },
  components: {},
  mounted() {
    this.loadBook("/static/book.epub");
  },
  methods: {
    // 设置主题
    setTheme(index) {
      this.active = index;
    },
    // 关闭弹框
    closePop() {
      this.isMenu = false;
    },
    // 打开目录
    openMenu() {
      this.isMenu = !this.isMenu;
    },
    // 加载书籍
    loadBook(path) {
      this.book = ePub({
        bookPath: path,
        width: 866,
        height: 602,
        restore: false,
        spreads: false
      });
      this.book.renderTo("area").then(() => {
        this.setStyle();
        // this.book.goto('epubcfi(/6/6[id71]!/4[0-622b49af2d5d40458b0c96129dcf4ccb]/2/2[calibre_pb_0]/1:0)')
      });
    },
    // 上一页
    prev() {
      this.book.prevPage();
    },
    // 下一页
    next() {
      this.book.nextPage();
    },
    // 进入全屏模式
    fullscreen() {
      console.log("全屏1");
      var de = document.documentElement;
      console.log("全屏2");
      if (de.requestFullscreen) {
        de.requestFullscreen();
      } else if (de.mozRequestFullScreen) {
        de.mozRequestFullScreen();
      } else if (de.webkitRequestFullScreen) {
        de.webkitRequestFullScreen();
      }
    },
    //设置epub内容样式
    setStyle() {
      if (!this.book) {
        return;
      }
      this.book.setStyle("font-size", "18px");
      //   this.book.setStyle("background-color", this.options.bgColor);
      //   this.book.setStyle("font-family", this.options.fontFamily);
      this.book.setStyle("line-height", 2);
      this.book.setStyle("color", "#80807c");
      //   this.book.setStyle("background-color",this.themes[this.options.theme].bgColor);
    }
  }
};
</script>
<style lang="less" scoped>
.book-content {
  .content {
    width: 966px;
    height: 642px;
    background: #f8f3e9;
    margin: 66px auto;
    border-radius: 10px;
    position: relative;
    box-shadow: #e6e6e6 2px 6px 2px;
    .fade {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0px;
      left: 0px;
      background: rgba(0, 0, 0, 0.7);
      cursor: pointer;
    }
    .menu-list {
      height: 100%;
      width: 0;
      background: #fff;
      position: absolute;
      right: 0px;
      top: 0px;
      transition: all 0.3s;
      overflow: hidden;
      .list-content {
        position: relative;
        width: 483px;
        height: 100%;
        .list-area {
          overflow-y: scroll;
          height: calc(100% - 85px);
          ul {
            padding: 20px 10px;
            li {
              border-bottom: 1px solid #c1c1c1;
              padding: 15px 0px;
              color: #80807c;
              display: flex;
              justify-content: space-between;
            }
            li:last-child {
              border-bottom: none;
            }
          }
        }
        .list-area::-webkit-scrollbar {
          display: none;
        }
      }
      .title {
        margin: 35px auto 20px auto;
        width: 294px;
        height: 45px;
        line-height: 45px;
        text-align: center;
        display: block;
        background-color: #f2ebe5;
        border-radius: 5px;
        color: #80807c;
        font-size: 18px;
      }
      .close {
        position: absolute;
        top: 20px;
        right: 26px;
        cursor: pointer;
        user-select: none;
      }
    }
    .menu-list.active {
      width: 483px;
    }
    #area {
      padding: 20px 50px;
    }
    .page {
      width: 78px;
      height: 302px;
      background: #f8f3e9;
      position: absolute;
      border-radius: 10px;
      right: -98px;
      bottom: 20px;
      .prev,
      .next {
        display: block;
        height: 150px;
        position: relative;
        cursor: pointer;
      }
      .next {
        border-bottom: 1px solid #e8e3da;
      }
      .prev:after {
        content: "";
        position: absolute;
        left: calc(50% - 5px);
        top: calc(50% - 10px);
        display: inline-block;
        width: 20px;
        height: 20px;
        border-top: 2px solid #000;
        border-right: 2px solid #000;
        transform: rotate(-135deg);
      }
      .next:after {
        content: "";
        position: absolute;
        left: calc(50% - 15px);
        top: calc(50% - 10px);
        display: inline-block;
        width: 20px;
        height: 20px;
        border-top: 2px solid #000;
        border-right: 2px solid #000;
        transform: rotate(45deg);
      }
    }
    .menu {
      height: 155px;
      width: 78px;
      background: #f8f3e9;
      position: absolute;
      border-radius: 10px;
      right: -98px;
      top: 145px;
      span {
        display: block;
        height: 67px;
        text-align: center;
        border-bottom: 1px solid #e8e3da;
        cursor: pointer;
        padding-top: 10px;
        .iconfont {
          display: block;
          background: url("/static/images/book/menu.png") no-repeat;
          width: 30px;
          height: 30px;
          margin: 0 auto;
          background-position: -30px 0;
        }
      }
      span:nth-child(2) {
        .iconfont {
          background-position: -60px 0;
        }
      }
      span:last-child {
        border-bottom: none;
      }
    }
    .history {
      width: 60px;
      height: 60px;
      text-align: center;
      border-radius: 10px 0 0 10px;
      position: absolute;
      background: #15c798;
      cursor: pointer;
      img {
        width: 30px;
        height: 30px;
        display: block;
        margin: 5px auto 0 auto;
      }
      div {
        // flex: 1;
        color: #fff;
        font-size: 14px;
        display: block;
        position: relative;
      }
    }
    .history {
      left: -60px;
      top: 20px;
    }
  }
}
</style>


